package cn.wolfcode.luowowo.website.controller;

import cn.wolfcode.luowowo.article.service.IStrategyCommendService;
import cn.wolfcode.luowowo.article.service.ITravelCommendService;
import cn.wolfcode.luowowo.article.service.ITravelService;
import cn.wolfcode.luowowo.common.query.TravelQuery;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {
    @Reference
    private IStrategyCommendService strategyCommendService;
    @Reference
    private ITravelCommendService travelCommendService;
    @Reference
    private ITravelService travelService;

    @RequestMapping("/")
    public String index(Model model) {
        //按照推荐序号,共享五篇攻略和游记
        model.addAttribute("scs", strategyCommendService.selectTop5());
        model.addAttribute("tcs", travelCommendService.selectTop5());
        return "index/index";
    }

    @RequestMapping("/index/travelPage")
    public String travelPage(@ModelAttribute("qo")TravelQuery qo, Model model){
        model.addAttribute("pageInfo", travelService.query(qo));
        return "index/travelPageTpl";
    }
}
